package com.jifeng.sterilizer.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.jifeng.sterilizer.entity.LiquidEntity;
import com.jifeng.sterilizer.service.LiquidService;
import com.jifeng.sterilizer.utils.PageUtils;
import com.jifeng.sterilizer.utils.R;



/**
 * 药剂表
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-07-26 15:15:15
 */
@RestController
@RequestMapping("sterilizer/liquid")
public class LiquidController {
    @Autowired
    private LiquidService liquidService;

    /**
     * 药剂搜索 PC
     */
    @GetMapping("/pc/drug/management/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = liquidService.queryPage(params);

        return R.ok().put("page", page);
    }

    // 修改药剂状态 PC
    @PostMapping("/pc/drug/management/changeTime")
    public R changeTime(@RequestBody Map<String, Object> params){
        R rs=liquidService.changeTime(params);
        return rs;
    }

    // 逻辑删除 PC
    @PostMapping("/pc/drug/management/del")
    public R del(@RequestBody Map<String, Object> params){
        R rs=liquidService.del(params);
        return rs;
    }

    /**
     * 获取药剂信息
     */
    @GetMapping("/info")
    public R info(@RequestParam Map<String, Object> params){
		R rs = liquidService.getInfo(params);

        return rs;
    }

//    @GetMapping("/info/{id}")
//    public R info(@PathVariable("id") Long id){
//		LiquidEntity liquid = liquidService.getById(id);
//
//        return R.ok().put("liquid", liquid);
//    }

    /**
     * 新增药剂 PC
     */
    @PostMapping("/pc/drug/management/add")
    public R save(@RequestBody Map<String, Object> params){
        R rs = liquidService.add(params);
        return rs;
    }

    /**
     * 修改药剂 PC
     */
    @PostMapping("/pc/drug/management/update")
    public R update(@RequestBody Map<String, Object> params){
        R rs = liquidService.myUpdate(params);
        return rs;
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		liquidService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
